package com.abc.cloud.dao;

import com.abc.cloud.dto.menu.MenuDto;
import com.abc.cloud.entity.MenuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 菜单表
 * 
 * @author LiJunXi
 * @email 2770063826@qq.com
 * @date 2023-10-27 13:09:54
 */
@Mapper
public interface MenuDao extends BaseMapper<MenuEntity> {

    List<MenuEntity> queryUserMenuList(Long userId);

    List<MenuEntity> getMenuAllList();

    @Select("select am.id, am.name, am.icon, am.title, am.hidden, am.sort " +
            "from tb_user account, tb_user_role_relation ar, tb_role_menu_relation ram, tb_menu am " +
            "where account.username = #{username} and ram.menu_id = am.id and ram.role_id = ar.role_id " +
            "and ar.user_id = account.id")
    List<MenuDto> selectMenuByUsername(String username_);

    @Select("select count(*) from tb_menu")
    Integer queryMenuTotal();


    @Select("select * from tb_menu")
    List<MenuEntity> selectMenuList();
}
